package com.projectName.www.service;

import com.projectName.www.dao.*;
import com.projectName.www.po.Dish;
import com.projectName.www.po.Order;
import com.projectName.www.po.User;

import java.math.BigDecimal;
import java.util.List;

public class SlrServiceImpl extends UserServiceImpl implements SlrService{

    //修改店铺名称简介
    @Override
    public void setName(String uid,String newName){
        UserDao ud=new UserDaoImpl();
        User me = ud.findByID(uid);
        me.setUserName(newName);
        //更新下我自己捏
        ud.update(me);
    }

    //在自己的店铺中发放抵用券
    @Override
    public void pushDiscount(String uid, BigDecimal money){
        UserDao ud=new UserDaoImpl();
        User me = ud.findByID(uid);
        me.setDiscount(money);


    }

    //查看自己的订单
    @Override
    public List<Order> findOrder(String uid) {

        OrderDao od=new OrderDaoImpl();
        List<Order> orderBySlr = od.findOrderBySlr(uid);
        return orderBySlr;

    }


    /**
     * 显示菜品
     * @param uid
     * @return
     */
    public List<Dish> showDishes(String uid){
        DishDao dd=new DishDaoImpl();
        List<Dish> dishList=dd.findBySlr(uid);
        return dishList;
    }

    /**
     * 添加一个菜品
     * @param dish
     */
    public void addDish(Dish dish) {
        DishDao dd=new DishDaoImpl();
        dd.insert(dish);

    }

    //上传菜品图片
    //根据菜品id修改修改菜品的价格，数量
    public void update(Dish dish) {
        DishDao dd=new DishDaoImpl();
        dd.update(dish);
    }




}
